#coding=utf-8
import xlrd
from selenium import webdriver
from xlwt import *
import time
file=xlrd.open_workbook('./list.xls')
sheet1=file.sheets()[0]

nrows=sheet1.nrows
browser=webdriver.Chrome()


file = Workbook(encoding = 'utf-8')
sheet=file.add_sheet('房源列表url')

list = 0
for i in range(nrows):
    url = sheet1.row_values(i)[0]
    print(url)
    browser.get(url)
    time.sleep(0.01)

    items = browser.find_element_by_xpath('/html/body/section[2]/div[1]').find_elements_by_class_name('item')
    # print(items)  for i in range(len(infor)):
    for index in range(len(items)):
        url=items[index].find_element_by_class_name('pic').find_element_by_class_name('item-link')
        href=url.get_attribute('href')
        print(href)
        sheet.write(list,0,href)
        list += 1
        time.sleep(0.01)
browser.quit()
file.save('house.xls')